home *** CD-ROM | disk | FTP | other *** search
/ Java Primer Plus / Java Primer Plus (Waite Group Proess)(1996).iso / chapter9 / confuse.java next >
Text File  |  1995-12-31  |  456b  |  26 lines

  1. /* confuse the compiler */
  2.  
  3.     class confusion {
  4.  
  5.      public confusion() {};
  6.  
  7.      public void nothing(char x)  {System.out.println("char");}
  8.      public void nothing(short x) {System.out.println("short");}
  9.  
  10.     }
  11.  
  12.  
  13.     class test {
  14.  
  15.     public static void main (String args[]) {
  16.  
  17.      confusion total = new confusion();
  18.     
  19.      int x = 99;            // compiler cant decide this
  20. //     byte x = 99;            // this would be ok
  21.  
  22.      total.nothing(x);        // ambiguous
  23.  
  24.     }
  25.      }
  26.